<template>
  <div>
    <van-row>
      <van-col span="12">
        <font color="#5f9ea0" size="5">申请消息处理状态</font>
        <table align="center">
          <tr align="center" v-for="i in tasklist" :key="i.tid" @click="info(i.tid)">
            <th>{{i.tid}}</th>
            <th>{{i.tname}}</th>
            <th><font color="blue">查看详情</font></th>
          </tr>
        </table>
        <el-dialog v-model="show">
          <table>
            <tr v-for="i in this.mes" :key="i.id">
              <th>id:{{i.id}}</th>
              <th>是否同意：{{i.is_agree}}</th>
              <th>原因:{{i.resason}}</th>
              <th>任务id:{{i.taskid}}</th>
              <th>审批人:{{i.userid}}</th>
              <th>审批人姓名:{{i.username}}</th>
              <th>审批时间:{{i.add_time}}</th>
            </tr>
          </table>
        </el-dialog>
      </van-col>
      <van-col span="12">
        <font color="#5f9ea0" size="5">消息通知</font>
        <table align="center">
          <tr align="center" v-for="i in noticelists" :key="i.id" @click="noticeinfo(i.id)">
            <th>{{i.id}}</th>
            <th>{{i.title}}</th>
            <th><font color="blue">查看详情</font></th>
          </tr>
        </table>
        <el-dialog v-model="show1">
          <table>
            <tr>
              <th>id:{{noticelist.id}}</th>
              <th>标题：{{noticelist.title}}</th>
              <th>消息类型:{{noticelist.noticetype}}</th>
              <th>开始时间:{{noticelist.stime}}</th>
              <th>结束时间:{{noticelist.etime}}</th>
              <th>通知人员:{{ noticelist.type }}</th>
              <th>内容:{{noticelist.content}}</th>
            </tr>
          </table>
        </el-dialog>
      </van-col>
    </van-row>
  </div>
</template>

<script>
import myaxios from "../../../https/myaxios";

export default {
  name: "mymes",
  data(){
    return{
      tasklist:[],
      mes:[],
      userid:localStorage.getItem("userid"),
      show:false,
      show1:false,
      noticelists:[],
      noticelist:[],
    }
  },
  filters:{
    my_filters(v){
      if(v=="3"){
         v = "全体员工"
      }
      return v
    }
  },
  methods:{
    noticeinfo(id){
      myaxios("mynoticemes?userid="+this.userid+'&id='+id,'get').then(res=>{
        this.noticelist=res.noticelist
        console.log(this.noticelist)
      })
      this.show1=true
    },
    changetime(mytime){
      const mydate = String(mytime).split(" ")
      // console.log(mydate[3],mydate[1],mydate[2])
      if(mydate[2]=="Jan"){
        mydate[2]="01"
      }else if(mydate[2]=="Feb"){
        mydate[2]="02"
      } else if(mydate[2]=="Mar"){
        mydate[2]="03"
      }else if(mydate[2]=="Apr"){
        mydate[2]="04"
      }else if(mydate[2]=="Mar"){
        mydate[2]="05"
      }else if(mydate[2]=="Jun"){
        mydate[2]="06"
      }else if(mydate[2]=="Jul"){
        mydate[2]="07"
      }else if(mydate[2]=="Aug"){
        mydate[2]="08"
      }else if(mydate[2]=="Sep"){
        mydate[2]="09"
      }else if(mydate[2]=="Oct"){
        mydate[2]="10"
      }else if(mydate[2]=="Nov"){
        mydate[2]="11"
      }else if(mydate[2]=="Dec"){
        mydate[2]="12"
      }
      let time = mydate[3] + "-" + mydate[2] + "-" + mydate[1]+' '+ mydate[4]
      return time
    },
    info(val){
      this.show=true
      for(let i=0;i<this.tasklist.length;i++){
        if(this.tasklist[i]["tid"]==val){
          this.mes=this.tasklist[i]["list"]
          for(let j=0;j<this.mes.length;j++){
            if(this.mes[j]["is_agree"]==1){
              this.mes[j]["is_agree"] = "同意"
            }else {
              this.mes[j]["is_agree"] = "不同意"
            }
            this.mes[j]["add_time"] = this.changetime(this.mes[j]["add_time"])
          }
        }
      }
    },
    getdata(){
      myaxios("mymes?userid="+this.userid,"get").then(res=>{
        this.tasklist=res.list
        // for(let i=0;i<this.tasklist.length;i++){
        //   this.mes.push(this.tasklist[i]["list"])
        // }
        this.noticelists=res.noticelist
      })
    },
  },
  mounted() {
    this.getdata()
  }
}
</script>

<style scoped>

</style>